<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>学生管理系统-晴空</title>
	<link rel="stylesheet" href="<?php echo (HOME_CSS); ?>public.css">
	<link rel="stylesheet" href="<?php echo (HOME_CSS); ?>list.css">
	<script src="<?php echo (HOME_JS); ?>jquery.min.js"></script>
</head>
<body>
	<div id="header" class="header clearfix">
		<div class="logo left">
			晴空-学生管理系统
		</div>
		<ul class="header-nav right">
			<li>
				<a href="<?php echo U('Manager/login');?>">登陆</a>
			</li>
			<li>
				<a href="<?php echo U('Manager/logout');?>">退出系统</a>
			</li>
		</ul>
	</div>
	<div id="main-wrapper" class="clearfix">
		<div id="side" class="left">
			<ul>
				<h3>学生信息管理</h3>
				<?php if(strstr($auth_path, 'Student-showList') != false): ?><li><a href="<?php echo U('Student/showList');?>">查询学生信息</a></li><?php endif; ?>
				<?php if(strstr($auth_path, 'Student-addInfo') != false): ?><li><a href="<?php echo U('Student/addInfo');?>">录入学生信息</a></li><?php endif; ?>
			</ul>
			<ul>
				<h3>课程信息管理</h3>
				<?php if(strstr($auth_path, 'Course-showList') != false): ?><li><a href="<?php echo U('Course/showList');?>">查询课程</a></li><?php endif; ?>
				<?php if(strstr($auth_path, 'Course-addInfo') != false): ?><li><a href="<?php echo U('Course/addInfo');?>">录入课程</a></li><?php endif; ?>
			</ul>
			<ul>
				<h3>学生成绩管理</h3>
				<?php if(strstr($auth_path, 'Score-showList') != false): ?><li><a href="<?php echo U('Score/showList');?>">查询成绩</a></li><?php endif; ?>
				<?php if(strstr($auth_path, 'Score-addInfo') != false): ?><li><a href="<?php echo U('Score/addInfo');?>">录入成绩</a></li><?php endif; ?>
			</ul>
		</div>
		<div id="main" class="right">
			<link rel="stylesheet" href="<?php echo (HOME_CSS); ?>input.css">
<style>
	.head {
		width: 100%;
		text-align: center;
		margin-top: 30px;
	}
	table {
		width: 600px;
		border: 1px solid #ddd;
		margin: 20px auto;
	}
	td {
		border: 1px solid #ddd;
		padding: 6px 8px;
		height: 30px;
		line-height: 30px;
		text-align: center;
		color: #336699;
	}
	td input[type="text"] {
		width: 100%;
		border: 1px solid #eee;
		color: #ff0000;
		padding: 6px 8px;
		font-size: 14px;
		text-align: center;
		-webkit-box-sizing: border-box;
		-moz-box-sizing: border-box;
		box-sizing: border-box;
	}
	.tips {
		text-align: center;
		line-height: 30px;
		font-size: 16px;
		font-weight: 700;
		color: #339933;
	}
	#loading {
		width: 50px;
		height: 50px;
		background: #fff url(<?php echo (HOME_IMG); ?>loading.gif) no-repeat scroll center center;
		border: 1px solid #ddd;
		border-radius: 5px;
		box-shadow: 2px 1px 1px #888;
		position: fixed;
		left: 0;
		top: 0;
		z-index: 99999;
		display: none;
	}
	#mask {
		width: 100%;
		height: 100%;
		background-color: rgba(255,255,255,0.1);
		position: fixed;
		top: 0;
		left: 0;
		z-index: 99998;
		display: none;
	}
</style>
<ul class="breadcrumb clearfix">
	<span>当前位置：</span>
	<li>
		<a href="<?php echo U('Score/showList');?>">
			学生成绩管理
		</a>
	</li>
	<li>
		&gt;
	</li>
	<li>
		学生成绩录入
	</li>
</ul>
<h1>学生成绩录入</h1>
<div id="cont">
	<div class="scoreAdd">
		<div class="head">
			班级:
			<select name="class_id" id="select-class">
				<?php if(is_array($class_info)): foreach($class_info as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>" <?php echo ($v['id'] == $class_id ? 'selected' : ''); ?>><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
			</select>
			&nbsp;
			&nbsp;
			&nbsp;
			&nbsp;
			课程:
			<select name="course_id" id="select-course">
				<?php if(is_array($course_info)): foreach($course_info as $key=>$v): ?><option value="<?php echo ($v["id"]); ?>" <?php echo ($v['id'] == $course_id ? 'selected' : ''); ?>><?php echo ($v["name"]); ?></option><?php endforeach; endif; ?>
			</select>
		</div>
		<table>
			<tr>
				<?php if(is_array($student_info)): $i = 0; $__LIST__ = $student_info;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 5 );++$i;?><td>
						<?php echo ($v["name"]); ?>
						<input type="text" class="score" name="score" value="<?php echo (getScore($v["id"],$course_id)); ?>" data-id="<?php echo ($v["id"]); ?>" placeHolder="成绩">
					</td>
					<?php if(($mod) == "4"): ?></tr><tr><?php endif; endforeach; endif; else: echo "" ;endif; ?>
			</tr>
		</table>
		<p class="tips">请在学生名字下方输入分数!</p>
		<div id="loading"></div>
		<div id="mask"></div>
	</div>
</div>
<script>
	$('#select-class').change(function(){
		window.location.href = "<?php echo U('Score/addInfo');?>" + '?class_id=' + $(this).val() + '&course_id=' + "<?php echo ($course_id); ?>"; 
	});
	$('#select-course').change(function(){
		window.location.href = "<?php echo U('Score/addInfo');?>" + '?class_id=' + "<?php echo ($class_id); ?>" + '&course_id=' + $(this).val(); 
	});

	$('.score').blur(function(){
		if( $(this).val() != '' ) {
			var id = $(this).attr('data-id');
			var class_id = <?php echo ($class_id); ?>;
			var course_id = <?php echo ($course_id); ?>;
			var score = $(this).val();

			$('#mask').show();
			$('#loading').css({
				'left' : ($(window).outerWidth() - $('#loading').outerWidth()) / 2,
				'top' : ($(window).outerHeight() - $('#loading').outerHeight()) / 2
			}).show();

			// 发送数据到后台
			$.post("<?php echo U('Score/addInfo');?>",{
				'student_id' : id,
				'class_id' : class_id,
				'course_id' : course_id,
				'score' : score
			},function(msg){
				if(msg != "SUCCESS") {
					alert('保存分数失败');
				}
				$("#loading").hide();
				$("#mask").hide();
			})

		}
	});

</script>

		</div>
	</div>
	<div class="footer" id="footer">
		<div class="copyright">
			copyright ---- 晴空
		</div>
	</div>
</body>
</html>